#ifndef PSO_VECTOR_HPP_
#	define PSO_VECTOR_HPP_

#	include <vector>
#	include <cassert>
#	include "PSOTools.hpp"

class PSOVector
{
	public:
		PSOVector(unsigned inD)
			: veData(inD, 0)
		{}
		
		float 	operator[](unsigned inI) const
		{
			return veData[inI];
		}
		
		PSOVector&	operator+=(const PSOVector& inPV)
		{
			assert(inPV.veData.size() == veData.size());
			
			for (unsigned register i = 0 ; i < veData.size() ; i++)
				veData[i] += inPV[i];
				
			return (*this);
		}
		
		PSOVector&	operator-=(const PSOVector& inPV)
		{			
			assert(inPV.veData.size() == veData.size());
			
			for (unsigned register i = 0 ; i < veData.size() ; i++)
				veData[i] -= inPV[i];
				
			return (*this);
		}
		
		PSOVector&	operator*=(float inScal)
		{
			for (unsigned register i = 0 ; i < veData.size() ; i++)
				veData[i] *= inScal;
				
			return (*this);
		}
		
		unsigned	size() const
		{
			return	(veData.size());
		}
		
	protected:
		std::vector<float>	veData;
};

class PSOPosition : PSOVector
{
	public:
		PSOPosition(unsigned inD)
			: PSOVector(inD)
		{}
		
		PSOPosition&	operator+=(const PSOVector& inPV)
		{
			assert(inPV.size() == veData.size());
			
			for (unsigned register i = 0 ; i < veData.size() ; i++)
			{
				veData[i] += inPV[i];
				
				if (veData[i] > PSO_MAX_POSITION)
					veData[i] = PSO_MAX_POSITION;
				else if (veData[i]  < PSO_MIN_POSITION)
					veData[i] = PSO_MIN_POSITION;
			}
			
			return (*this);
		}
		
		PSOPosition&	operator-=(const PSOVector& inPV)
		{
			assert(inPV.size() == veData.size());
			
			for (unsigned register i = 0 ; i < veData.size() ; i++)
			{
				veData[i] -= inPV[i];
				
				if (veData[i] > PSO_MAX_POSITION)
					veData[i] = PSO_MAX_POSITION;
				else if (veData[i]  < PSO_MIN_POSITION)
					veData[i] = PSO_MIN_POSITION;
			}
			
			return (*this);
		}
		
		PSOVector&	operator*=(float inScal)
		{
			for (unsigned register i = 0 ; i < veData.size() ; i++)
			{
				veData[i] *= inScal;
				
				if (veData[i] > PSO_MAX_POSITION)
					veData[i] = PSO_MAX_POSITION;
				else if (veData[i]  < PSO_MIN_POSITION)
					veData[i] = PSO_MIN_POSITION;
			}
			
			return (*this);
		}
};

#endif
